from boot import QFrame, QHBoxLayout, QVBoxLayout, QWidget, Qt, Union, GlobalWidgetConfig, IMG_ROOT_DIR
from view.widget.qq9_line_edit import QQ9SearchLineEdit
from view.widget.qq9_button import QQ9SquareButton


__all__ = ["SearchListBase"]


class SearchListBase(QFrame):

    def __init__(self, parent: Union[QWidget, None] = None):
        super().__init__(parent=parent)

        # 基础设置
        self.setFixedHeight(80)

        # 主水平布局
        self.main_h_layout = QHBoxLayout()
        self.main_h_layout.setContentsMargins(10, 0, 10, 0)
        self.main_h_layout.setSpacing(5)
        self.setLayout(self.main_h_layout)

        # 搜索框
        self.search_line_edit = QQ9SearchLineEdit()

        # 新建按钮
        self.add_button = QQ9SquareButton(
            icon_path=IMG_ROOT_DIR + "/add.png",
            tips="新建"
        )

        # 筛选按钮
        self.filter_button = QQ9SquareButton(
            icon_path=IMG_ROOT_DIR + "/filter.png",
            tips="筛选"
        )

        # 刷新按钮
        self.refresh_button = QQ9SquareButton(
            icon_path=IMG_ROOT_DIR + "/refresh.png",
            tips="刷新"
        )

        # 截屏按钮
        self.screenshot_button = QQ9SquareButton(
            icon_path=IMG_ROOT_DIR + "/screenshot.png",
            tips="截屏"
        )

        # 编辑按钮
        self.edit_button = QQ9SquareButton(
            icon_path=IMG_ROOT_DIR + "/edit.png",
            tips="编辑"
        )

        # 删除按钮
        self.delete_button = QQ9SquareButton(
            icon_path=IMG_ROOT_DIR + "/delete.png",
            tips="删除"
        )

        # PDF按钮
        self.pdf_button = QQ9SquareButton(
            icon_path=IMG_ROOT_DIR + "/screenshot.png",
            tips="PDF"
        )

        self._set_style_sheet()

    def _set_style_sheet(self):
        self.setStyleSheet(
            """
            SearchListFrame {
                background-color: #FFFFFF;
                border: none;
            }
            """
        )